<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace='SysConfig' xmlns='http://ibatis.apache.org/mapping' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  <alias>
    <typeAlias alias='SysConfig' assembly='Janus.Mes.POCO.dll' type='Janus.Mes.POCO.SysConfig' />
  </alias>
  <resultMaps>
    <resultMap id='SysConfigResult' class='SysConfig'>
	<result property='Key' column='Key ' /> 
	<result property='Value' column='Value ' /> 
	<result property='Title' column='Title ' /> 
	<result property='IsSys' column='IsSys ' /> 
		</resultMap>
  </resultMaps>  
  <statements>
  <sql id="UpdaterConditions">  
  <dynamic prepend="SET">
      	<isPropertyAvailable prepend="" property="Value">
        <isNotEmpty prepend="," property="Value">
		          [Value]=#Value#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="Title">
        <isNotEmpty prepend="," property="Title">
		          [Title]=#Title#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="IsSys">
        <isNotEmpty prepend="," property="IsSys">
		          [IsSys]=#IsSys#
		          </isNotEmpty>
      </isPropertyAvailable>	
	  	 </dynamic>
    </sql>
	<sql id="WhereConditions">
	 <dynamic prepend="WHERE">
	 	 <isPropertyAvailable prepend="" property="Key">
        <isNotEmpty prepend="AND" property="Key">
		          [Key]=#Key#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="Value">
        <isNotEmpty prepend="AND" property="Value">
		          [Value]=#Value#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="Title">
        <isNotEmpty prepend="AND" property="Title">
		          [Title]=#Title#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="IsSys">
        <isNotEmpty prepend="AND" property="IsSys">
		          [IsSys]=#IsSys#
		          </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic> 
    </sql>
	<sql id="InsertPublic">
      INSERT INTO SysConfig(
	     <dynamic prepend=" ">
       	   <isPropertyAvailable prepend="" property="Key">
        <isNotEmpty prepend="," property="Key">
          [Key]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="Value">
        <isNotEmpty prepend="," property="Value">
          [Value]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="Title">
        <isNotEmpty prepend="," property="Title">
          [Title]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="IsSys">
        <isNotEmpty prepend="," property="IsSys">
          [IsSys]
        </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic>
      )
      VALUES
      (
	   <dynamic prepend=" ">
      	<isPropertyAvailable prepend="" property="Key">
        <isNotEmpty prepend="," property="Key">		
         #Key#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="Value">
        <isNotEmpty prepend="," property="Value">		
         #Value#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="Title">
        <isNotEmpty prepend="," property="Title">		
         #Title#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="IsSys">
        <isNotEmpty prepend="," property="IsSys">		
         #IsSys#		
        </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic>
      )
    </sql>
	<!-- Insert statement:新增Mapper-->
    <insert id='Insert' parameterClass='SysConfig'>
      <include refid="InsertPublic"/>
    </insert>
    <!--Update statement:修改Mapper-->
    <update id='Update' parameterClass='SysConfig'>
      UPDATE [SysConfig] 
      <include refid="UpdaterConditions"/>
      WHERE 1=1
	  	  AND Key=#Key#
	      </update>
    <update id='UpdateSetion' parameterClass='hashtable'>
      UPDATE [SysConfig] 
      <include refid="UpdaterConditions"/>
      WHERE $conditions$
    </update>
	<update id='Save' parameterClass='SysConfig'>
      IF NOT EXISTS(SELECT 1 FROM [SysConfig] WHERE 1=1  AND [Key]=#Key# )
      BEGIN
      <include refid="InsertPublic"/>
      END
      ELSE
      BEGIN
      UPDATE SysConfig 
      <include refid="UpdaterConditions"/>
      WHERE  1=1
	  	  AND [Key]=#Key#
	        END
    </update>
	<delete id='Delete' parameterClass='hashtable'>
      DELETE FROM [SysConfig] WHERE	  
        <![CDATA[  
	 [Key]=#pk0# 
        ]]>
    </delete>
    <delete id='DeleteWhere' parameterClass='string'>
      DELETE FROM [SysConfig] WHERE $value$
    </delete>

    <!-- select by key statement:-->
    <select id='FindOne' parameterClass='hashtable' resultClass='SysConfig'>
      SELECT * FROM SysConfig WHERE      
        <![CDATA[
		[Key]=#pk0# 
        ]]>
    </select>
    <select id='FindAllCondition' parameterClass='string' resultClass='SysConfig'>
      SELECT * FROM [SysConfig] WHERE $value$
    </select>
    <select id='FindScalar' parameterClass='hashtable' resultClass='SysConfig'>
      SELECT * FROM [SysConfig] WHERE $conditions$
    </select>
    
    <select id='FindAllCount' parameterClass='string' resultClass='int'>
      SELECT COUNT(1) FROM [SysConfig] WHERE $value$
    </select>
    <select id='FindByPage' parameterClass='string' resultClass='SysConfig'>
      SELECT * FROM [SysConfig] WHERE $value$
    </select>
  </statements>
</sqlMap>
